using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Xml;
using System.Xml.Schema;

namespace miciv
{
    public delegate void ScreenSizeChangedHandler(int _sWidth, int _sHeight);

    public class CoreContext
    {
        protected class Data<T>
        {
            protected T m_data;

            public Data(T _data)
            {
                this.m_data = _data;
            }

            public T DataValue
            {
                get
                {
                    return this.m_data;
                }
            }

            public Type DataType
            {
                get
                {
                    return typeof(T);
                }
            }
        }

        protected Hashtable m_htblDatas;

        protected CoreManager m_coreManager;
        public CoreManager CoreManager
        {
            get
            {
                return this.m_coreManager;
            }
            set
            {
                this.m_coreManager = value;
            }
        }

        public CoreContext()
        {
            this.m_htblDatas = new Hashtable();
        }

        public bool AddData<T>(string _strName, T _data)
        {
            if (false == this.m_htblDatas.ContainsKey(_strName))
            {
                this.m_htblDatas.Add(_strName, new Data<T>(_data));
                return true;
            }
            return false;
        }

        public T GetData<T>(string _strName)
        {
            if (false != this.m_htblDatas.ContainsKey(_strName))
            {
                Data<T> data = this.m_htblDatas[_strName] as Data<T>;
                return data.DataValue;
            }
            return default(T);
        }

        public void RemoveData(string _strName)
        {
            if (false != this.m_htblDatas.ContainsKey(_strName))
            {
                this.m_htblDatas.Remove(_strName);
            }
        }

        public bool ReplaceData<T>(string _strName, T _data)
        {
            RemoveData(_strName);
            return AddData(_strName, _data);
        }
    }
}
